package easier.app.x;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.content.Context;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import easier.app.x.view.EditInputManager;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith( AndroidJUnit4.class )
public class ExampleInstrumentedTest {

    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        assertEquals( "easier.app.x.test", appContext.getPackageName() );
    }

    @Test
    public void testIsNumberAndLetter() {

        String s = "AaBbCcDd";
        assertFalse( EditInputManager.checkNumberAndLetter( s ) );

        String s1 = "1234567890";
        assertFalse( EditInputManager.checkNumberAndLetter( s1 ) );

        String s2 = s + s1;
        assertTrue( EditInputManager.checkNumberAndLetter( s2 ) );

        String s4 = s + "曾经" + s1;
        assertFalse( EditInputManager.checkNumberAndLetter( s4 ) );

        String s5 = s + "---" + s1;
        assertFalse( EditInputManager.checkNumberAndLetter( s5 ) );
    }

    @Test
    public void testSfzLastNumber() {

        String s = "131002199008260012";
        assertTrue( EditInputManager.checkSfz( s ) );

        String s1 = "131002199008260012";
        assertTrue( EditInputManager.checkSfzLastNumber( s1 ) );
    }
}